/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.ds2.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Eli
 */
@Entity
@Table(name = "sales")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sales.findAll", query = "SELECT s FROM Sales s"),
    @NamedQuery(name = "Sales.findByIdsale", query = "SELECT s FROM Sales s WHERE s.idsale = :idsale"),
    @NamedQuery(name = "Sales.findByFolio", query = "SELECT s FROM Sales s WHERE s.folio = :folio"),
    @NamedQuery(name = "Sales.findByTotal", query = "SELECT s FROM Sales s WHERE s.total = :total")})
public class Sales implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idsale")
    private Integer idsale;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "folio")
    private String folio;
    @Basic(optional = false)
    @NotNull
    @Column(name = "total")
    private float total;
    @JoinColumn(name = "idsaleDetail", referencedColumnName = "idsailDetail")
    @ManyToOne(optional = false)
    private SaleDetails idsaleDetail;

    public Sales() {
    }

    public Sales(Integer idsale) {
        this.idsale = idsale;
    }

    public Sales(Integer idsale, String folio, float total) {
        this.idsale = idsale;
        this.folio = folio;
        this.total = total;
    }

    public Integer getIdsale() {
        return idsale;
    }

    public void setIdsale(Integer idsale) {
        this.idsale = idsale;
    }

    public String getFolio() {
        return folio;
    }

    public void setFolio(String folio) {
        this.folio = folio;
    }

    public float getTotal() {
        return total;
    }

    public void setTotal(float total) {
        this.total = total;
    }

    public SaleDetails getIdsaleDetail() {
        return idsaleDetail;
    }

    public void setIdsaleDetail(SaleDetails idsaleDetail) {
        this.idsaleDetail = idsaleDetail;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idsale != null ? idsale.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sales)) {
            return false;
        }
        Sales other = (Sales) object;
        if ((this.idsale == null && other.idsale != null) || (this.idsale != null && !this.idsale.equals(other.idsale))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mx.itsc.ds2.model.Sales[ idsale=" + idsale + " ]";
    }
    
}
